home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Topik / Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].zip / Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].adf / plotxy / PlotXY.doc < prev    next >
Text File  |  1991-03-11  |  22KB  |  552 lines

  1.  
  2.  
  3.                             PlotXY Version 1.1
  4.                                    By
  5.                               Robert Mack
  6.                             Copyright, 1989
  7.  
  8.  
  9.   
  10.  
  11.  
  12.  1 Introduction 
  13.    ------------
  14.  
  15.        PlotXY is a 2-D plotting package that plots X and Y data points 
  16.    from a file on several types of graphs.  PlotXY was written completely
  17.    in C using the Manx Aztec V3.6a C compiler.  PlotXY was compiled using
  18.    the +fi option for the IEEE Double Precision Floating Point Emulation
  19.    and linked using the mal32.lib for access to the Amiga's library.
  20.  
  21.        There are several good plotting programs in the public domain,
  22.    but the majority of them accept only a mathematical function as
  23.    input (as far as I know).  I wanted a plotting package that
  24.    accepted X and Y data points as input.  I also wanted it to be very
  25.    flexible as far as the output was concerned.  PlotXY allows the user 
  26.    to define just about every aspect of the plot that I could think of.
  27.    The user can determine the type of graph (i.e. linear, linear-log, 
  28.    log-linear, log-log, and histogram), the size of the graph (by input 
  29.    or interactively), the color of the graph and data, the marker type, 
  30.    the line type (although there are only 6 pre-defined types), annotation
  31.    and title, and the graph characteristics (i.e. X /Y bounds, major/minor
  32.    tick marks, grid, and overlay option).  Also included are linear 
  33.    regression analysis and polynomial fit analysis.  All these options 
  34.    are explained in detail section 3.
  35.  
  36.       PlotXY is in the public domain.  The author grants permission 
  37.    to duplicate this software provided that no commercial gain can be 
  38.    had as a consequence of use or reproduction of this software and 
  39.    that this and other identifying information be left intact.  The author 
  40.    may not be held liable for the consequences of use or misuse of this 
  41.    software.  
  42.  
  43.  1.1  What's new in Version 1.1
  44.      --------------------------
  45.  
  46.       The new features for PlotXY Version 1.1 are denoted by a " * " 
  47.    next to the item.  The following is a brief description of the
  48.    new features and some bug fixes:
  49.  
  50.       1)  The integer gadgets had a format bug that caused the system
  51.           to sometimes hang.  This is now fixed.  Thanks to EKIM (Plink ID).  
  52.  
  53.       2)  I changed the the number type from float to exponent for
  54.           the regression output as suggested by OES895 (Plink ID).
  55.  
  56.       3)  The filter (smooth) function had a slight bug.  It refused
  57.           to smooth the first 3 numbers.  This is now fixed.
  58.  
  59.       4)  The linetype would not get set back to the correct 
  60.           type after linear or polynomial regression functions
  61.           were executed.  This bug is fixed.
  62.  
  63.       5)  I redesigned the color and line type gadgets.  (I was 
  64.           experimenting with PowerWindows 2.0).
  65.  
  66.       6)  I made the string gadget that requested text look a
  67.           little better.
  68.  
  69.       7)  I added Steve Tibbett's Simple Requesters because I thought
  70.           they were better looking than the systems, easy to
  71.           implement, and more flexible.  (The OKAY gadgets can be
  72.           turned off by typing any key).
  73.  
  74.       8)  I improved the histogram.  I also added two more types.
  75.           Besides the standard, there is now the probability and 
  76.           cumulative histogram.  See section 3.2 for more details.
  77.  
  78.       9)  Added statistics to the analysis menu.  See section 3.3.
  79.  
  80.      10)  Added the capability to contour an X, Y, Z field (were Z is
  81.           is some parameter at a location X and Y of a grid).  See
  82.           section 3.2.6.
  83.  
  84.      11)  I made an Icon for PlotXY.
  85.  
  86.      12)  Last and maybe least, I removed my name from the title
  87.           bar and put in under the menu item "About" in the 
  88.           Project menu.  The version number can also be found here.
  89.  
  90.  
  91.  2. How to get started using PlotXY (see section 3.2 for contour plots)
  92.     -------------------------------
  93.  
  94.        I've provided several example input files so that you may
  95.    experiment with PlotXY.  The files are:
  96.  
  97.        lotto.dat   Frequency of the Maryland Lotto numbers
  98.                    picked from the beginning to 01/14/89.
  99.  
  100.        sine.dat    The sine of 0 to 360 degrees.
  101.  
  102.        tempf.dat   The temperatures (degrees Fahrenheit) at Baltimore 
  103.                    for 72 hours (I don't remember the dates...sometime
  104.                    in the fall).
  105.        
  106.    The following is an example of typical steps that are used 
  107.    to plot a X/Y graph with PlotXY.
  108.  
  109.     1) PLOTXY expects there to be a logical device "GDATA:", which 
  110.        corresponds to the directory where the data for plotting is
  111.        located.  This can be accomplished using the CLI "ASSIGN"
  112.        command (i.e., ASSIGN GDATA: DF1:Graphdata).
  113.  
  114.     2)  Open and read the data file.  Choose the menu item "Open"
  115.         in the project menu.  A file requester is presented for 
  116.         selection.
  117.  
  118.     3)  Choose the graph type under the "Graph Type" menu.
  119.  
  120.     4)  Next choose the graph options that you want under the Utilities
  121.         menu.  The default is a point plot.  You may also choose to
  122.         plot a line connecting the data points.  The point, line, grid,
  123.         and overlay options can all be activated at the same time.
  124.         They are not mutually exclusive.  If they are activated, a
  125.         check mark will appear be for an item.  To turn them off, you
  126.         must reselect the item.  The check mark will no longer be
  127.         displayed.
  128.  
  129.     5)  Choose the graph and background colors from the "Color" menu.
  130.  
  131.     6)  Plot the graph using the Draw item under the "Project" menu.
  132.  
  133.  
  134.  3. Description of Menu Items
  135.     -------------------------
  136.  
  137.  3.1     Project Menu
  138.  
  139.  3.1.1   Draw 
  140.         
  141.          This menu item initiates the plotting of the graph.  After
  142.          the user acknowledges that he/she wants to begin, a setup
  143.          window appears.  This window allows the user to set up 
  144.          different plot characteristics (see Setup description below 
  145.          for details).  If a contour map is going to be drawn the
  146.          user is prompted for a file name after the Draw item is
  147.          selected (see section 3.2.6 for more details).
  148.  
  149.  3.1.1.1 Setup
  150.  
  151.          Setup opens a window with gadgets that allow the user
  152.          to change the graph characteristics.  The following is 
  153.          a list of graph characteristics that can be changed:
  154.  
  155.          1) Graph Bounds (float)
  156.          -----------------------
  157.          XMAX - X maximum
  158.          XMIN - X minimum
  159.          YMAX - Y maximum
  160.          YMIN - Y minimum
  161.              
  162.          Initially the graph bounds default to the X and Y data bounds
  163.          (X and Y minimum and maximum).  Log plots default to 
  164.          XMAX and YMAX = 1000.0 and XMIN and YMIN = 1.0.
  165.  
  166.          2) Tick marks (integer)
  167.          -----------------------
  168.          XMAJ - major tick marks along the X axis. Default is 5.
  169.          YMAJ - major tick marks along the Y axis. Default is 5.
  170.          XMINOR - minor tick marks along the X axis. Default is 5.
  171.          YMINOR - minor tick marks along the Y axis. Default is 5.
  172.  
  173.          3) Box size (float)
  174.          -------------------
  175.          XUL - The pixel upper left hand corner of the graph.
  176.          YUL - The line upper left hand corner of the graph.
  177.          Width - The graph width.
  178.          Height - The graph height.
  179.  
  180.          4) Features 
  181.          -----------
  182.          Marker type - The marker type specifies what character is
  183.                        drawn to mark the data point.  The default is
  184.                        "+".  WARNING: The character font I use is
  185.                        the Siesta font (Microsmiths).  I adjusted the
  186.                        X and Y coordinates for the TEXT command to make 
  187.                        the characters draw so that the data point is
  188.                        at the middle of the character.  I checked the
  189.                        default Topaz font and it looks okay, but other 
  190.                        fonts may not be centered.  If this is a problem,
  191.                        let me know.  I use the Siesta font because it
  192.                        looks the best (IMHO). 
  193.  
  194.          Data color - Change the color for the data.  Default is green.
  195.                       See color menu for default colors.
  196.  
  197.          Precision - Precision is the number of decimal places that 
  198.                      are plotted to the right of the decimal point 
  199.                      (i.e. 0 plots integer).  The default is 1.
  200.  
  201.          Line pattern - Change the line pattern. The line option must
  202.                         be active.  The default is a solid line.
  203.  
  204.  
  205.  3.1.2   Open 
  206.  
  207.          Open a text file containing n points to plot (max 1000).  The
  208.          file must have the following format:
  209.  
  210.             record 1     Number of points (integer)
  211.  
  212.             record 2        X1                Y1
  213.             
  214.             record 3        X2                Y2
  215.  
  216.               .             .                 .
  217.             
  218.               .             .                 .
  219.  
  220.             record i        Xn                Yn
  221.  
  222.          X and Y can be either floating point or integer. If you plan
  223.          on doing a line plot make sure the points are sorted.  PlotXY
  224.          does NOT sort the points.  A file requester will be presented
  225.          for file selection.
  226.  
  227.  3.1.3   New 
  228.        
  229.          Erase the screen (plot) for a new plot. The file opened
  230.          previously is still active.
  231.  
  232.  3.1.4   SaveIFF 
  233.  
  234.          Save the screen (plot) as an IFF file.  A file requester
  235.          will appear for the user to enter the IFF file name.
  236.  
  237.  3.1.5   Print 
  238.  
  239.          Print the screen (plot) to a dot matrix line printer.  There
  240.          is an option to set the background color to white for 
  241.          printing on a black and white dot matrix printer. (I've
  242.          never tried it on a color printer).
  243.  
  244.  3.1.6   Credits 
  245.  
  246.          This item displays a window that gives credit for the
  247.          public domain routines that were used.  Thank you. 
  248.  
  249.  3.1.7   About *
  250.  
  251.          My name and the PlotXY version number.
  252.  
  253.  3.1.8   Quit 
  254.  
  255.          Quit PlotXY.
  256.  
  257.  
  258.  3.2     Graph Type Menu
  259.  
  260.  3.2.1   Linear 
  261.  
  262.          Indicates a linear graph is desired (default).
  263.  
  264.  3.2.2   Linear-Log 
  265.  
  266.          Indicates a linear (X) - log (Y) graph is desired.
  267.  
  268.  3.2.3   Log-Linear 
  269.  
  270.          Indicates a log (X) - linear (Y) graph is desired.
  271.  
  272.  3.2.4   Log-Log 
  273.      
  274.          Indicates a log graph is desired.
  275.  
  276.  3.2.5   Histogram *
  277.  
  278.  
  279.  3.2.5.1 Standard Histogram 
  280.  
  281.          Indicates a standard histogram graph is desired
  282.          (X versus Y value).  The abscissa represents values
  283.          of the variate and the ordinate represents the
  284.          class frequencies.  The histogram consists of 
  285.          adjacent rectangular boxes whose bases extend between
  286.          successive mathematical limits and whose heights are 
  287.          equal to the frequency within each class. The rectangular
  288.          boxes are plotted with the center at the mid-points
  289.          of the class intervals.
  290.  
  291.  3.2.5.2 Probability Histogram 
  292.  
  293.          Indicates a probability histogram graph is desired
  294.          (X versus Y value expressed as a percentage of the total).
  295.          This histogram is analogous to the standard histogram,
  296.          except that the height of the boxes is not the class 
  297.          frequency but the class frequency divided by N, the 
  298.          total observations.
  299.  
  300.  3.2.5.3 Cumulative Frequency Histogram (Ogive)
  301.  
  302.          Indicates a cumulative frequency histogram graph is 
  303.          desired (X versus the cumulative sum of the Y values 
  304.          expressed as a percentage of the total).  Values range 
  305.          from 0 to 100 percent. It is useful in determining the 
  306.          distribution of an element in terms of "more than" or 
  307.          "less than" a certain value (e.g., the median is the  
  308.          value of X at 50%). The abscissa shows the successive
  309.          upper mathematical limits (just as does the abscissa
  310.          of a standard histogram) and the ordinate shows the 
  311.          percentage frequency less than each mathematical 
  312.          limit.  For each upper limit, there exists one
  313.          cumulative frequency percentage.  These points are
  314.          plotted and connected by a straight line (set the
  315.          "Line" option in order to connect the points).  Thus,
  316.          the ogive always starts at the point of zero frequency
  317.          on the graph and ends at the point of 100%, or total 
  318.          frequency.
  319.  
  320.  3.2.5.4 How Histogram Works
  321.  
  322.          Follow the first 6 steps in section 2 for drawing
  323.          a regular plot.  The following are additional steps:
  324.  
  325.          7)  A window will open listing the histogram parameters
  326.              that can be changed.  The first parameters have to do 
  327.              with the class intervals.  The lower limit of the first 
  328.              and last class interval can be adjusted.  The class
  329.              interval is determined by the range of X values 
  330.              and the class interval size (see bin size described 
  331.              below).  The defaults have been initially set to the
  332.              minimum and maximum values of X.  The bin size should
  333.              be chosen to given equal class intervals (bins).  Unequal
  334.              intervals are not supported.  The lower limits of the 
  335.              first and last lower limits for the class interval 
  336.              should be set based on the equal class intervals.
  337.              The second parameter that can be changed is the bin
  338.              size (class interval size).  The default is set to 1.
  339.              I chose these defaults for a discrete case.  That
  340.              is, there is only frequency data for each X value and
  341.              not for a range of X values.  (See the lotto.dat case
  342.              provided).
  343.  
  344.          8)  Select the "OK" gadget to continue or the "NO"
  345.              gadget to cancel the histogram plot.
  346.   
  347.          9)  Next the familiar "Setup" window will be displayed.
  348.              Adjust the plot characteristics accordingly.  The
  349.              histogram will then be plotted.
  350.           
  351.  
  352.  3.2.6   Contour* 
  353.  
  354.          Indicates a contour plot is desired.
  355.  
  356.  3.2.6.1 How Contour Works
  357.  
  358.        I've provided one example grid input file so that you may
  359.    experiment with the contour option in PlotXY.  The file is 
  360.    "pres.grd".  I generated this atmospheric surface pressure 
  361.    (millibars) grid field using weather service observations from 
  362.    the central United States.  From the observations I performed 
  363.    an objective analysis using M.I.P.S (Meteorological Information
  364.    Processing System) that I wrote for use on my Amiga. (I'm a 
  365.    meteorologist by profession.)
  366.        
  367.    The following is an example of typical steps that are used 
  368.    to generate a contour map.
  369.  
  370.     1) PLOTXY expects there to be a logical device "GDATA:", which 
  371.        corresponds to the directory where the data for contouring is
  372.        located.  This can be accomplished using the CLI "ASSIGN"
  373.        command (i.e., ASSIGN GDATA: DF1:Graphdata).
  374.  
  375.     2)  Choose the graph type "Contour" under the "Graph Type" menu.
  376.  
  377.     3)  Open and read the data file.  Choose the menu item "Draw"
  378.         in the project menu.  A file requester is presented for 
  379.         selection.  (Note:  This is different from the procedure 
  380.         to plot a normal X/Y graph where the "Open" item was used.)
  381.         Choose the grid file (i.e., pres.grd).        
  382.  
  383.     5)  Next, a window will appear showing options for contour 
  384.         plotting.  The window shows the number of contour levels
  385.         (maximum is 10).  This number can be changed.  The window
  386.         also shows the values for each contour level.  The first
  387.         is the minimum data value and the last is the maximum. 
  388.         The other eight values are are at equal intervals between
  389.         the min and max.  These can also be changed.  Finally, select
  390.         the color and line type for each contour interval.  Select
  391.         the "Okay" gadget to draw the plot or "Cancel" to exit. 
  392.         
  393.  3.2.6.2 Grid File Format
  394.  
  395.          Record 1     nx ny          
  396.          Record 2     X1Y1   X1Y2  ...  X1Yny
  397.          Record 3     X2Y1   X2Y2  ...  X2Yny
  398.             .          .      .     .     .
  399.             .          .      .     .     .
  400.             .          .      .     .     .
  401.          Record nx+1  XnxY1  XnxY2 ...  XnxYny
  402.  
  403.         where nx and ny are the number of x and y grid points 
  404.         (integer) and XiYi are the grid locations of parameter 
  405.         Z (float).
  406.  
  407.  3.3     Analysis Menu
  408.  
  409.  3.3.1   Linear Regression 
  410.  
  411.          Linear regression allows you to analyze one
  412.          variable's relationship to another.  The method
  413.          is to perform a least-squares linear regression
  414.          which is designed to minimize the sum of the
  415.          squares of the deviations of the actual data 
  416.          points from the straight line of best fit.  In
  417.          practice, a plot of the data points is made
  418.          and then a line is constructed (by selecting
  419.          the Linear Regression Item) that uniformly 
  420.          divides the points.  The data color and line 
  421.          type is chosen at this point.  The line is 
  422.          described by y = mx + b, where m is the slope 
  423.          of the line and b is the intercept.  The 
  424.          correlation coefficient, which is a measurement 
  425.          of how well the line fitted to the data actually 
  426.          does approximate the data, is also calculated.  
  427.          These parameters are displayed in a separate 
  428.          window.
  429.  
  430.  3.3.2   Polynomial Fit 
  431.  
  432.          Polynomial fit uses a higher order polynomial
  433.          for a reasonably good representation of a series
  434.          of n data points (X,Y).  The regression coefficients
  435.          are also estimated.  The technique employs a
  436.          least-squares fit of the data by a polynomial of
  437.          order m, where m = 1,2,...10 (maximum of 10) and
  438.          examines the standard deviation s about the regression
  439.          line.  The linear regression of Y upon a single 
  440.          variable X can be extended to the multiple regression:
  441.          Y = a + b1X1 + b2x2 + ... + biXi + ... + bkXk,
  442.          where X1,X2,...,Xk are k different variables.  If, as
  443.          frequently occurs, X1 = X, X2 = X**2, X3 = X**3, etc.,
  444.          we have a special case of multiple regression known as
  445.          polynomial or curvilinear regression.
  446.  
  447.          After the data points have been plotted, select
  448.          the Polynomial Fit item under the Analysis menu.  
  449.          The user is then prompted, via a integer string gadget,
  450.          to enter the order of the polynomial that will be used.
  451.          Next, the color and line type are selected.  A curve 
  452.          is then plotted on the graph.  A separate window is 
  453.          presented that displays: 1) the polynomial order, 
  454.          2)the standard deviation, 3) the coefficient a, and 
  455.          4) each bk regression coefficient.
  456.  
  457.  3.3.3   Statistics *
  458.  
  459.          The following statistics are calculated and displayed
  460.          in a separate window:
  461.  
  462.                         mean
  463.                         mean deviation
  464.                         standard deviation
  465.                         variance
  466.  
  467.  3.4     Utilities Menu
  468.  
  469.  3.4.1   Point 
  470.  
  471.          Plot a character marker for the data point (default).  
  472.  
  473.  3.4.2   Line 
  474.  
  475.          Plot a line connecting the data points.
  476.  
  477.  3.4.3   Grid 
  478.  
  479.          Plot a dashed grid at the major tick marks on the 
  480.          background.
  481.  
  482.  3.4.4   Overlay 
  483.  
  484.          This option is used to overlay data from a different
  485.          file onto the previous graph.  If this item is picked,
  486.          the previous options remain.  All that is plotted are
  487.          the new data points.
  488.                
  489.  3.4.5   Box Mode 
  490.  
  491.          Enables the user to shape and move the graph box
  492.          interactively via the mouse.  Menu options control 
  493.          whether the box is being sized (shaped) or moved.  
  494.          Use the left mouse button to define the box. Initially 
  495.          this option is set to shape the box.  Exit when you 
  496.          are satisfied with the size and location.
  497.                 
  498.  
  499.  3.4.6   Filter 
  500.  
  501.          This option does a running mean on the Y data to 
  502.          perform a smoothing.  Enter the number of Y data points
  503.          to use in the running mean.  The data points must be sorted.
  504.  
  505.  3.4.7   Annotate 
  506.  
  507.          This option allows the user to write text for the plot.
  508.          A string gadget is presented for input of a character
  509.          string of up to a maximum of 132 characters.  Move the 
  510.          text with the mouse to the location desired.  Define 
  511.          the location by pressing the left mouse button.
  512.  
  513.  3.4.8   Title 
  514.  
  515.          This option lets the user write a title in the window's
  516.          title bar.  The string may be up to a maximum of 132 
  517.          characters. 
  518.  
  519.  3.5     Colors 
  520.  
  521.          Default colors: black, blue, green, cyan, red, magenta, 
  522.          yellow, and white.
  523.  
  524.  3.5.1   Background 
  525.  
  526.          Set the background color by selecting the appropriate
  527.          box (default: black).
  528.  
  529.  3.5.2   Foreground 
  530.  
  531.          Set the graph color by selecting the box (default: blue).
  532.  
  533.  3.5.3   Palette 
  534.  
  535.          Make your own palette by using C. Heath's public domain
  536.          palette tool.
  537.  
  538.  4.0  Remarks
  539.       -------
  540.  
  541.        PlotXY is my first program that I have released as public domain.
  542.     I've learned how to program in C on my Amiga writing PlotXY and other
  543.     programs.  Therefore, I am very interested in any comments, suggestions,
  544.     and complaints that you may have.  Please let me here from you.  I can
  545.     be reached on BIX as RMACK or PLINK as OTR763. You can also write
  546.     me:
  547.  
  548.               Bob Mack
  549.               13909 Briarwood Drive Apt. 312
  550.               Laurel, Maryland 20708
  551.  
  552.